unit DuplicataPagSearchFr;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ExtCtrls, Buttons, StdCtrls, DBGrids, EditBtn, MainSearchFr;

type

  { TDuplicataPagSearchFrame }

  TDuplicataPagSearchFrame = class(TMainSearchFrame)
    BitBtn1: TBitBtn;
    data_vencimento: TDateEdit;
    id_duplicata_pagar: TEdit;
    id_fornecedor: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    nome_pessoa: TEdit;
    status: TRadioGroup;
    procedure BitBtn1Click(Sender: TObject);
    procedure LocalizarButtonClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

implementation

uses QueryConditions, DuplicataPagDM, MainFr, Initializator;

{ TDuplicataPagSearchFrame }

procedure TDuplicataPagSearchFrame.LocalizarButtonClick(Sender: TObject);
var
  condicoes: TQueryConditions;
  valor: string;
begin
  if (status.ItemIndex = 0) then begin
    valor := 'A';
  end else if (status.ItemIndex = 1) then begin
    valor := 'Q';
  end else if (status.ItemIndex = 2) then begin
    valor := 'C';
  end;
  condicoes := TQueryConditions.Create(CON_AND);
  condicoes.AddJoinField('d.id_fornecedor', 'f.id_fornecedor');
  condicoes.AddJoinField('p.id_pessoa', 'f.id_fornecedor');
  condicoes.Add('d.id_duplicata_pagar', id_duplicata_pagar.Text);
  condicoes.Add('d.id_fornecedor', id_fornecedor.Text);
  condicoes.AddText('p.nome_pessoa', nome_pessoa.Text);
  condicoes.Add('d.status', valor);
  condicoes.Add('d.data_vencimento', data_vencimento.Text);
  DuplicataPagData.Search(Condicoes,
    'duplicata_pagar as d, fornecedor as f, pessoa as p');
end;

procedure TDuplicataPagSearchFrame.BitBtn1Click(Sender: TObject);
begin
  TheControl.ShowForeignFrame(TMainFrame(FornecedorSearchFrame));
end;

initialization
  {$I duplicatapagsearchfr.lrs}

end.
